package org.jeecg.modules.basic.demo.apartment.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.basic.demo.apartment.entity.LwgyBaseApartment;
import org.jeecg.modules.basic.demo.apartment.entity.LwgyBaseApartmentDistribute;
import org.jeecg.modules.basic.demo.apartment.entity.LwgyBaseApartmentDistributeXy;
import org.jeecg.modules.basic.demo.apartment.service.ILwgyBaseApartmentDistributeService;
import org.jeecg.modules.basic.demo.apartment.service.ILwgyBaseApartmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: 房源分配管理
 * @Author: sn
 * @Date: 2021-10-25
 * @Version: V1.0
 */

@Api(tags = "房源分配管理")
@RestController
@RequestMapping("/apartment/LwgyBaseApartmentDistributeController")
@Slf4j
public class LwgyBaseApartmentDistributeController extends JeecgController<LwgyBaseApartment, ILwgyBaseApartmentService> {
    @Autowired
    private ILwgyBaseApartmentDistributeService iLwgyBaseApartmentDistributeService;

    @AutoLog(value = "获取所有校区")
    @ApiOperation(value = "获取所有校区", notes = "获取所有校区")
    @GetMapping(value = "/queryDistributeXqList")
    public Result<?> queryDistributeXqList() {
        try {
            List<LwgyBaseApartmentDistribute> list = iLwgyBaseApartmentDistributeService.queryDistributeXqList();
            return Result.OK(list);
        }catch (Exception error){
            log.error(error.getMessage(), error);
            return Result.error("获取房间分配情况失败:"+error.getMessage());
        }
    }

/*    @AutoLog(value = "通过校区id获取楼宇信息")
    @ApiOperation(value = "通过校区id获取楼宇信息", notes = "通过校区id获取楼宇信息")
    @GetMapping(value = "/queryDistributeLhList")
    public Result<?> queryDistributeLhList(String campusId) {
        try {
            List<LwgyBaseApartmentDistribute> list = iLwgyBaseApartmentDistributeService.queryDistributeLhList(campusId);
            return Result.OK(list);
        }catch (Exception error){
            log.error(error.getMessage(), error);
            return Result.error("获取房间分配情况失败:"+error.getMessage());
        }
    }*/

    @AutoLog(value = "通过校区id获取楼宇信息(带房源分布情况)")
    @ApiOperation(value = "通过校区id获取楼宇信息(带房源分布情况)", notes = "通过校区id获取楼宇信息(带房源分布情况)")
    @GetMapping(value = "/queryDistributeLhMoreList")
    public Result<?> queryDistributeLhMoreList(String campusId) {
        try {
            List<LwgyBaseApartmentDistribute> list = iLwgyBaseApartmentDistributeService.queryDistributeLhMoreList(campusId);
            return Result.OK(list);
        }catch (Exception error){
            log.error(error.getMessage(), error);
            return Result.error("获取楼宇分配情况失败:"+error.getMessage());
        }
    }
    @AutoLog(value = "通过单元id获取房间房源分布情况")
    @ApiOperation(value = "通过单元id获取房间房源分布情况", notes = "通过单元id获取房间房源分布情况")
    @GetMapping(value = "/queryRoomList")
    public Result<?> queryRoomList(String unitId,String chId) {
        try {
            List<LwgyBaseApartmentDistribute> list = iLwgyBaseApartmentDistributeService.queryRoomList(unitId,chId);
            return Result.OK(list);
        }catch (Exception error){
            log.error(error.getMessage(), error);
            return Result.error("获取房间分配情况失败:"+error.getMessage());
        }
    }

    @AutoLog(value = "通过单元id获取床位学生信息情况")
    @ApiOperation(value = "通过单元id获取床位学生信息情况", notes = "通过单元id获取床位学生信息情况")
    @GetMapping(value = "/queryDistributeRoomList")
    public Result<?> queryDistributeRoomList(String unitId) {
        try {
            List<LwgyBaseApartmentDistribute> list = iLwgyBaseApartmentDistributeService.queryDistributeRoomList(unitId);
            return Result.OK(list);
        }catch (Exception error){
            log.error(error.getMessage(), error);
            return Result.error("获取房间分配情况失败:"+error.getMessage());
        }
    }



    @AutoLog(value = "获取学院辅导员信息")
    @ApiOperation(value = "获取学院辅导员信息", notes = "获取学院辅导员信息")
    @GetMapping(value = "/queryDistributeFdyList")
    public Result<?> queryDistributeFdyList(String campusId,String collegeId) {
        try {
            List<LwgyBaseApartmentDistributeXy> list = iLwgyBaseApartmentDistributeService.queryDistributeFdyList(campusId,collegeId);
            return Result.OK(list);
        }catch (Exception error){
            log.error(error.getMessage(), error);
            return Result.error("获取房间分配情况失败:"+error.getMessage());
        }
    }

/*    @AutoLog(value = "获取某个辅导员的房源分布信息（到楼宇）")
    @ApiOperation(value = "获取某个辅导员的房源分布信息（到楼宇）", notes = "获取某个辅导员的房源分布信息（到楼宇）")
    @GetMapping(value = "/queryDistributeLhByFdyList")
    public Result<?> queryDistributeLhByFdyList(@RequestParam List<String> adminId) {
        try {
            List<LwgyBaseApartmentDistribute> list = iLwgyBaseApartmentDistributeService.queryDistributeLhByFdyList(adminId);
            return Result.OK(list);
        }catch (Exception error){
            log.error(error.getMessage(), error);
            return Result.error("获取房间分配情况失败:"+error.getMessage());
        }
    }*/
/*    @AutoLog(value = "获取某个辅导员的房源分布详细信息(到房间)")
    @ApiOperation(value = "获取某个辅导员的房源分布详细信息(到房间)", notes = "获取某个辅导员的房源分布详细信息(到房间)")
    @GetMapping(value = "/queryDistributeRoomInfoByFdyList")
    public Result<?> queryDistributeRoomInfoByFdyList(String adminId,String buildingId) {
        try {
            List<LwgyBaseApartmentDistribute> list = iLwgyBaseApartmentDistributeService.queryDistributeRoomInfoByFdyList(adminId,buildingId);
            return Result.OK(list);
        }catch (Exception error){
            log.error(error.getMessage(), error);
            return Result.error("获取房间分配情况失败:"+error.getMessage());
        }
    }*/

    @AutoLog(value = "获取某个学院的房源分布详细信息(到楼宇)")
    @ApiOperation(value = "获取某个学院的房源分布详细信息(到楼宇)", notes = "获取某个学院的房源分布详细信息(到楼宇)")
    @GetMapping(value = "/queryDistributeLhInfoByCollegeIdList")
    public Result<?> queryDistributeLhInfoByCollegeIdList(String collegeId) {
        try {
            //查询某个学院下所有辅导员id
            List<String> list = iLwgyBaseApartmentDistributeService.queryDistributeFdyInfoByCollegeIdList(collegeId);
            List<LwgyBaseApartmentDistribute> list2 = new ArrayList<LwgyBaseApartmentDistribute>();
            if(list!=null && list.size()>0){
                 list2 = iLwgyBaseApartmentDistributeService.queryDistributeLhByFdyList(list);
            }
            return Result.OK(list2);
        }catch (Exception error){
            log.error(error.getMessage(), error);
            return Result.error("获取房间分配情况失败:"+error.getMessage());
        }
    }

}
